package net.cl.utils;

import java.io.IOException;

public class ExecUtil {

	public static String exec(String[] args) {
		Process p = null;
		try {
			Runtime r = Runtime.getRuntime();
			p = r.exec(args);
			p.waitFor();
			return IOUtil.toString(p.getInputStream());
		} catch (IOException e) {
			e.printStackTrace();
			return null;
		} catch (InterruptedException e) {
			e.printStackTrace();
			return null;
		} finally {
			p.destroy();
		}
	}

	public static void main(String[] args) {
		String s = exec(new String[] { "ping", "127.0.0.1" });
		System.out.println(s);
	}

}
